﻿using AuthCenter.Domain;
using AuthCenter.ErorCode;
using AuthCenter.Infrastructure;
using AuthCenter_API.Read.Applications.Commands.User;
using MediatR;
using Microsoft.IdentityModel.Tokens;

namespace AuthCenter_API.Read.Applications.CommandHandlers.User
{
    public class ShengQueryCommandHandler : IRequestHandler<ShengQueryCommand, APIResult<List<ShengModel>>>
    {
        private readonly IBaseRepository<ShengModel> _shengRepository;

        public ShengQueryCommandHandler(IBaseRepository<ShengModel> shengRepository)
        {
            _shengRepository = shengRepository;
        }

        public Task<APIResult<List<ShengModel>>> Handle(ShengQueryCommand request, CancellationToken cancellationToken)
        {
            APIResult<List<ShengModel>> result = new APIResult<List<ShengModel>>();
            result.Code = APIEnum.QuerySuccess;
            result.Message = APIEnum.QuerySuccess.Desc();
            var m = _shengRepository.GetAll().ToList();
            result.Data = m;
            return Task.FromResult(result);
        }
    }
}
